﻿using System;

namespace UDS.Management.Data.Package
{
    /// <summary>
    /// Represents the contents of a single Schema change
    /// </summary>
    public class SqlSchemaChange : IDisposable
    {
        private string m_description;
        private Guid m_id;
        private SqlSource[] m_scripts;

        public SqlSchemaChange(Guid id, string description, SqlSource[] sources)
        {
            m_id = id;
            m_description = description;
            m_scripts = sources;
        }

        ~SqlSchemaChange()
        {
            if (m_scripts != null)
            {
                foreach (SqlSource m_script in m_scripts)
                {
                    m_script.Dispose();
                }
            }
        }

        public SqlSource[] Scripts
        {
            get
            {
                return m_scripts;
            }
        }

        public string Description
        {
            get
            {
                return m_description;
            }
        }

        public Guid Id
        {
            get
            {
                return m_id;
            }
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (m_scripts != null)
            {
                foreach (SqlSource m_script in m_scripts)
                {
                    m_script.Dispose();
                }
            }
            GC.SuppressFinalize(this);
        }

        #endregion
    }
}
